/**
 * Created by wolfMan on 2025/07/11.
 */
import { mapGetters } from 'vuex';

export default {
  data () {
    return {
      showSearch: true,
      showFormMore: false,
      tableHeight: 500,
      // navbar: 44; app-main内外上下边距:40 pagination: 42; table外上间距: 10;
      othersHeight: 44 + 42 + 40 + 10
    };
  },
  computed: {
    ...mapGetters([
      'clientHeight',
      'isBigWindow'
    ])
  },
  watch: {
    clientHeight: function () {
      this.computedTableHeight();
    },
    showSearch: function () {
      this.computedTableHeight();
    },
    showFormMore: function () {
      setTimeout(() => {
        this.computedTableHeight();
      }, 500);
    }
  },
  mounted () {
    this.computedTableHeight();
  },
  methods: {
    /**
      * @date 2025/07/11
      * @author wolfMan
      * @description {计算列表页面表格高度}
    */
    computedTableHeight () {
      this.$nextTick(() => {
        // app-main 上下内边距
        let _noHeight = 0;
        // 页面 tab 模块高度
        if (this.$refs.pageTab) {
          _noHeight = this.$refs.pageTab.offsetHeight;
        };
        // 搜索框高度
        if (this.showSearch && this.$refs.topSearch) {
          _noHeight = _noHeight + this.$refs.topSearch.offsetHeight;
        };
        // 按钮模块高度
        if (this.$refs.rightToolbar) {
          _noHeight = _noHeight + this.$refs.rightToolbar.$el.offsetHeight;
        };
        if (this.othersHeight) {
          _noHeight = _noHeight + this.othersHeight;
        };
        this.tableHeight = this.clientHeight - _noHeight;
      });
    },
    /**
      * @date 2025/07/11
      * @author wolfMan
      * @description {显示更多条件}
    */
    searchShowMore () {
      this.$nextTick(() => {
        setTimeout(() => {
          this.showFormMore = !this.showFormMore;
        }, 500);
      });
    }
  }
};